﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SongsExtractorLINQ
{
    class SongsExtractor
    {
        static List<string> ExtractSongTitles(string xmlName)
        {
            XDocument doc = XDocument.Load(xmlName);
            var songs = from song in doc.Descendants("song")
                        select song.Element("title").Value;
            return songs.ToList<string>();
        }

        static void Main()
        {
            const string SourceXML = @"..\..\..\catalog.xml";

            List<string> allSongs = ExtractSongTitles(SourceXML);

            foreach (string song in allSongs)
            {
                Console.WriteLine(song);
            }
        }
    }
}
